package com.itheima.factorymethod;

public class FactoryMethod {
    public static void main(String[] args) {
        Factory factoryA = new FactoryA() ;
        Product productA = factoryA.createProduct() ;
        productA.info() ;
        Factory factoryB = new FactoryB() ;
        Product productB = factoryB.createProduct() ;
        productB.info() ;
    }
}

interface Factory {
    public Product createProduct() ;
}

class FactoryA implements Factory {
    @Override
    public Product createProduct() {
        return new ProductA();
    }
}

class FactoryB implements Factory {
    @Override
    public Product createProduct() {
        return new ProductB();
    }
}

interface Product {
    public abstract void info() ;
}

class ProductA implements Product {
    @Override
    public void info() {
        System.out.println("ProductA");
    }
}

class ProductB implements Product {
    @Override
    public void info() {
        System.out.println("ProductB");
    }
}
